<%@ include file="connect.jsp" %>

<%
    String learnid = request.getParameter("learn");
    String detaillearnid = request.getParameter("id");
    String word = request.getParameter("word");
    String definition = request.getParameter("arti");
    String partOfSpeech = request.getParameter("tipeword");
    String example = request.getParameter("contoh");
    String images = request.getParameter("image");
    String wordstem = request.getParameter("wordstem");
    String gantidef = definition.replaceAll("'", "''");
    String gantiex = example.replaceAll("'", "''");

    ResultSet rs = stat.executeQuery("select * from Learn where learnid ='" + learnid + "' and paragraph like '%" + word + "%'");
    if (rs.next()) {
        stat.executeUpdate("Update DetailLearn Set words='" + word + "',definition='" + gantidef + "',partofspeech='" + partOfSpeech + "',example='" + gantiex + "',images='" + images + "',wordstem='" + wordstem +
                "' where detaillearnid = " + detaillearnid);
        response.sendRedirect("EditLearn.jsp?respon=Successfully updated word&id=" + learnid);
    } else {
        response.sendRedirect("EditLearn.jsp?respon=Error! Please input the word that shown in the paragraph!&id=" + learnid);
    }

    conn.close();
%>